import React, { Component, lazy, Suspense } from 'react'
import { NavLink, Route, BrowserRouter } from 'react-router-dom'
import Loading from './Loading'
const Home = lazy(() => import("./Home"))
const About = lazy(() => import("./About"))

export default class Demo extends Component {
    render() {
        return (
            <div>
                <BrowserRouter>
                    <NavLink to="/about">About</NavLink>
                    <NavLink to="/home">Home</NavLink>
                    <Suspense fallback={<Loading />}>
                        <Route path="/about" component={About} />
                        <Route path="/home" component={Home} />
                    </Suspense>
                </BrowserRouter>
            </div>
        )
    }
}
